package com.zhengdongzulin.zuke.app.main.mine.contract

import androidx.lifecycle.rxLifeScope
import com.lxj.androidktx.livedata.StateLiveData
import com.zhengdongzulin.zuke.app.Api
import com.zhengdongzulin.zuke.app.data.ContractListData
import com.zhengdongzulin.zuke.base.BaseViewModel
import rxhttp.wrapper.param.RxHttp
import rxhttp.wrapper.param.toResponse

class ContractDetailsVm : BaseViewModel() {

    var contract_detail: StateLiveData<ContractListData> = StateLiveData()

    fun contract_detail(id: String) {
        rxLifeScope.launch(
            {
                var r = RxHttp.postJson(Api.CONTRACT_DETAIL)
                    .add("id", id)
                    .toResponse<ContractListData>()
                    .await()
                contract_detail.postValueAndSuccess(r)
            }, {
                assignment(it, contract_detail)
            }
        )
    }

}